import request from "@/utils/request";
import { headerOption } from "@/utils/allSM";
import store from "@/store";

/**
 * 获取智桂通用户信息
 * @param {*} data
 * @returns
 */
export function getUser(data) {
  return request({
    url: "/zgt/api/getUser",
    method: "post",
    params: data,
  });
}

/**
 * 获取token
 * @param {*} data
 * @returns
 */
export function getToken(data) {
  // headerOption
  return request({
    url: "/zgt/api/getToken",
    method: "post",
    params: data,
  });
}

/**
 * 获取区域与流程状态
 * @param {*} data
 * @returns
 */
export function getConsData() {
  let obj = headerOption(store.state.params);
  if (!obj) return Promise.reject(new Error("参数错误"));
  return request({
    url: "/zgt/api/getConsData",
    method: "post",
    headers: {
      ...obj,
    },
  });
}

/**
 * 购机者信息保存接口
 * @param {*} data
 * @returns
 */
export function saveBuyerInfo(data) {
  let obj = headerOption(store.state.params);
  if (!obj) return Promise.reject(new Error("参数错误"));
  return request({
    url: "/zgt/api/saveBuyerInfo",
    method: "post",
    headers: {
      ...obj,
    },
    data
  });
}

/**
 * 申请列表
 * @param {*} data
 * @returns
 */
export function getBuyerApplyList(data) {
  let obj = headerOption(store.state.params);
  if (!obj) return Promise.reject(new Error("参数错误"));
  return request({
    url: "/zgt/api/getBuyerApplyList",
    method: "post",
    headers: {
      ...obj,
    },
    data
  });
}

/**
 * 申请进度
 * @param {*} data
 * @returns
 */
export function getBuyerApplyInfo(data) {
  let obj = headerOption(store.state.params);
  if (!obj) return Promise.reject(new Error("参数错误"));
  return request({
    url: "/zgt/api/getBuyerApplyInfo",
    method: "post",
    headers: {
      ...obj,
    },
    data
  });
}
